﻿// It is important to place this JavaScript code after ScriptManager1
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandlerLanguage(sender, args) {
    if ($('#<%= upLanguage.ClientID %>') != null) {
        // Get X and Y positions of scrollbar before the partial postback
        xPos = $('#<%= upLanguage.ClientID %>').scrollLeft;
        yPos = $('#<%= upLanguage.ClientID %>').scrollTop;
    }
}

function EndRequestHandlerLanguage(sender, args) {
    if ($('#<%= upLanguage.ClientID %>') != null) {
        // Set X and Y positions back to the scrollbar
        // after partial postback
        $('#<%= upLanguage.ClientID %>').scrollLeft = xPos;
        $('#<%= upLanguage.ClientID %>').scrollTop = yPos;
    }
}

// prm.add_beginRequest(BeginRequestHandlerLanguage);
//prm.add_endRequest(EndRequestHandlerLanguage);
//Sys.Application.add_load(CloneLanguage);
//Sys.Application.add_load(LoadLanguage);

//Sys.Application.add_load(CloneQualification);
//Sys.Application.add_load(LoadQualification);
var countChildren;
var countLanChildren;
var qualifications = '';

// alert('edu')


var isLoaded = 0;
function GetSelectedLanguges() {
    //alert('GetSelectedLanguges');

    $('#ctl00_MainContent_lblOtherLanguageCheck').val("");
    GetTagsString1();

    var qualifications = "";
    $("#ctl00_MainContent_divQualificationContainer :text").each(function () {
        qualifications += $(this).val() + "~";
    });

    $('#ctl00_MainContent_hdQualifications').val(qualifications);

    var selectedLanWithPro;
    var cf = 0;
    var selectedValues;
    var selectedID = [];
    var arr = new Array();
    var arrSelectedLanCheck = new Array();
    var ii = 0;


    $('#ctl00_MainContent_upLanguage').find('select').each(function () {
        var innerDivId = $(this).attr('id');


        if (innerDivId != null && innerDivId.length != 0) {

            if (innerDivId.indexOf("ddlOtherLanguage") != -1) {
                var selectedValue = $('#' + innerDivId).find(":selected").text()

                if (selectedValue != null && selectedValue != "") {
                    arrSelectedLanCheck.push(selectedValue);
                }

            }
        }
    });
    arrSelectedLanCheck.push("Nepali");
    arrSelectedLanCheck.push("English");

    var preValue;
    var isDuplicate;;

    arrSelectedLanCheck.sort();
    //alert(arrSelectedLanCheck.length);

    for (var i = 0; i < arrSelectedLanCheck.length; i++) {

        if (preValue == arrSelectedLanCheck[i]) {
            isDuplicate = 'true';
            //alert('true');
            break;
            //alert('Can not select same language');
        }
        else {
            isDuplicate = 'false'
            // alert('false');
        }
        preValue = arrSelectedLanCheck[i];
        //alert(preValue);
    }
    if (isDuplicate == 'false') {
        $('#ctl00_MainContent_lblOtherLanguageCheck').val("");
    }
    else {
        $('#ctl00_MainContent_lblOtherLanguageCheck').val("1");
    }
}
function GetTagsString1() {
    // alert('GetTagsString');
    var values = [];
    $('#allowSpacesTags span.tagit-label').each(function () {
        //alert($(this).text());
        values.push($(this).text());
    });
    $("#ctl00_MainContent_hdnSelectedTags").val(values.join(","));
}